//角色全选树形控件全选控制JS
function showhide(li) {
	$("#li" + li).toggle();
	if ($("#img" + li).attr("src") == "images/1.jpg") {
		$("#img" + li).attr("src", "images/2.jpg");
	} else {
		$("#img" + li).attr("src", "images/1.jpg");
	}
}
function treeClick(id) {
	$('#roleId').attr("value", id);
	document.getElementById("myForm").submit();
}
// checkbox点击事件
function ConfirmDelete() {
	return confirm('确认删除');
}
function messageconfirm() {
	confirm('确认删除' + '<%=GetRoleName() %>' + '?');
}
function configmess(obj) {
	if ($("#HiddenField4").val() == 'edit') {
		var mess = "";
		if ($("#chkchangsuo").attr("checked") != true) {
			mess += '您未选择';
			mess += '用户继承场所权限';
		}
		if (mess != "") {
			mess += ".";
		}
		con('警告', mess + '确认要保存吗?', obj, 'BtnAdd');
	} else {
		__doPostBack('BtnAdd', '');
	}
}

// 百叶窗的获取值和全选JS
function systemcheck(i) {
	var title = "AccpContain";

	var Allcheckbox;
	var Alltable;
	var index = i * 2 + 1 + 4;
	// if (index > 9) {
	Allcheckbox = document.getElementById(title + (i) + '_cb' + i);
	Alltable = document.getElementById(title + (i) + '_tb' + i);
	// }
	// else {
	// Allcheckbox = document.getElementById(title + '0' + index + '_cb' + i)
	// Alltable = document.getElementById(title + '0' + index + '_tb' + i)
	// }
	var checks = Alltable.getElementsByTagName("input");
	var flag = Allcheckbox.checked;
	for ( var i = 0; i < checks.length; i++) {
		if (checks[i].type == "checkbox") {
			checks[i].checked = flag;
		}
	}
}

function aa(i, catelogid, index1) {
	var title = "AccpContain";
	var checkbox;
	var checkboxview;
	var index = i * 2 + 1 + 4;
	// if (index > 9) {
	checkbox = document.getElementById(title + (i) + '_' + catelogid + '-'
			+ index1);
	checkboxview = document
			.getElementById(title + (i) + '_' + catelogid + '-1');
	// }
	// else {
	// checkbox = document.getElementById(title + '0' + index + '_' + catelogid
	// + '-' + index1)
	// checkboxview = document.getElementById(title + '0' + index + '_' +
	// catelogid + '-1')
	// }

	if (checkbox.checked) {
		checkboxview.checked = true;
	} else {
		var allcheck = "AccpContain" + i + "_cb" + i;
		if ($('#' + allcheck)[0].checked) {
			$('#' + allcheck).attr("checked", "");
		}
	}
}
function aaa(obj) {
	var pre = $(obj).parent().parent().find("input");
	if ($(obj).attr("checked") == false) {
		for (i = 0; i < pre.size(); i++) {
			pre.eq(i).attr("checked", "");
		}
		// 去除全选按钮选中状态
		var id = obj.id.substring(11, 12);
		var allcheck = "AccpContain" + id + "_cb" + id;
		if ($('#' + allcheck)[0].checked) {
			$('#' + allcheck).attr("checked", "");
		}
	}

}

// 保存角色
function saveRole() {
	// 角色名称
	var roleName = $('#txtNewRoleName').val();
	if (roleName == "" || roleName == null) {
		myAlert("提示", "请输入角色名称！");
		return false;
	}
	document.getElementById("myForm").submit();
}

// 编辑
function roleManagerEdit() {
	var myForm = document.getElementById("myForm");
	myForm.action = "roleManagerEdit";
	myForm.submit();
}

// 编辑提交
function editRole() {
	// 角色名称
	var roleName = $('#txtNewRoleName').val();
	if (roleName == "" || roleName == null) {
		myAlert("提示", "请输入角色名称！");
		return false;
	}
	document.getElementById("myForm").submit();
}

// 保存配置
function saveConfig(tbid) {
	var checks = tbid.getElementsByTagName("input");
	var buttonString = "";
	for ( var i = 0; i < checks.length; i++) {
		if (checks[i].type == "checkbox") {
			if (checks[i].checked == true) {
				if (checks[i].name.indexOf("cb") == -1) {
					buttonString += checks[i].name + ",";
				}
			}
		}
	}
	buttonString = buttonString.substring(0, buttonString.length - 1);
	$('#buttonString').attr("value", buttonString);
	var myForm = document.getElementById("myForm");
	myForm.action = "saveConfig";
	myForm.submit();
}

// 初始化显示提示消息
function roleLoad() {
	var message = $('#message').val();
	if (message != null && message != '') {
		alert(message);
	}
	var divString = $('#divString').val();
	var div = divString.split(",");
	// for ( var i = 0; i < div.length; i++) {
	// $('#AccpContain' + div[i]).hide();
	// }
	// $('#AccpContain' + div[0]).show();
}

// 确定删除角色
function deleteRoleQd() {
	var myForm = document.getElementById("myForm");
	myForm.action = "deleteRole";
	myForm.submit();
};

// 删除角色
function deleteRole() {
	myConfirm("确定框", "您确定要删除该角色吗？", deleteRoleQd);
}

// 点击div
function divClick(id) {
	var divString = $('#divString').val();
	var div = divString.split(",");
	for ( var i = 0; i < div.length; i++) {
		$('#AccpContain' + div[i]).hide();
	}
	$('#AccpContain' + id).show();
}